package com.yx.config;

import com.yx.interceptor.JwtValidateInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
//jwt验证拦截器
//excludePathPatterns：排除以下接口
@Configuration
public class MyInterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private JwtValidateInterceptor jwtValidateInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration registration = registry.addInterceptor(jwtValidateInterceptor);
        registration.addPathPatterns("/**")
                .excludePathPatterns(
                        "/user/login",
                        "/user/info",
                        "/user/logout",
                        "/user/userMes",
                        "/user/fuzzyNickname",
                        "/user/username",
                        "/user/register",
                        "/user/reset",
                        "/error",
                        "/v3/**",
                        "/swagger-ui/**",
                        "/swagger-resources/**",
                        "/post/**",
                        "/tags/**",
                        "/image/**",
                        "/wiki/**",
                        "/edition/**",
                        "/express/**",
                        "/reply/list",
                        "/reply/parent",
                        "/verification/**"
                );
    }
}
